package com.ruoyi.datastatistics.service.impl;

import com.ruoyi.basedata.domain.vo.TerminalsDbProtocol;
import com.ruoyi.basedata.service.ITerminalsDbService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.CommonHelper;
import com.ruoyi.datastatistics.Agreement.MQTT_HaiAn;
import com.ruoyi.datastatistics.service.ITerminalDbCommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class TerminalDbCommandServiceImpl implements ITerminalDbCommandService {
    @Autowired
    private ITerminalsDbService terminalsDbService;

    @Override
    public AjaxResult terminalDbCommandPush(String supplierId, TerminalsDbProtocol terminalsDbProtocol, String commandType, Map<String,String> values,String url){
        switch(terminalsDbProtocol.getSignPlatform()){
            case 1://NB-AEP
                break;
            case 2://OneNet
                break;
            case 3://德高netty
                switch (terminalsDbProtocol.getProtocolId()){
                    case "7"://海安供水MQTT透传协议，可拓展，根据commandType类型进行不同命令的下发
//                        String val = values.get("isOpen");
                        Map<String,Object> map = MQTT_HaiAn.concatenateData(commandType,values,terminalsDbProtocol.getCommunicateAddress());
                        String res = CommonHelper.sendMqttMsg(map ,url,terminalsDbProtocol.getCommunicationType(),terminalsDbProtocol.getCommunicationConfig());
                        return AjaxResult.success(res);



                }
                break;
        }



        return null;
    }
}
